<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>询价单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="../../common/bootstrap/css/bootstrap.css" media="all">
    <link rel="stylesheet" type="text/css" href="../../common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="../../common/global.css" media="all">
    <link rel="stylesheet" type="text/css" href="../../css/customer_list.css" media="all">
</head>
<style>
    #roleAuthTable + .layui-table-view .layui-table tbody tr:hover {
        background-color: transparent;
    }
</style>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form toolbar layui-form-pane">
                <div class="layui-form-item">
                    <!--<div class="layui-inline">
                        <label class="layui-form-label w-auto">关键字</label>
                        <div class="layui-input-inline mr0">
                            <input id="keyWords" class="layui-input" type="text" placeholder="输入关键字"/>
                        </div>
                    </div>-->
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">询价单号</label>
                        <div class="layui-input-inline mr0">
                            <input name="bus_inquiry_no" id="bus_inquiry_no" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </div>
                    </div>
                    <!--<div class="layui-inline">-->
                        <!--<label class="layui-form-label w-auto">询价单位</label>-->
                        <!--<div class="layui-input-inline mr0">-->
                            <!--<input name="bus_from_company_name" id="bus_from_company_name" class="layui-input" type="text" placeholder="" autocomplete="off"/>-->
                        <!--</div>-->
                    <!--</div>-->
                    <div class="layui-inline">
                        <label class="layui-form-label">询价时间</label>
                        <div class="layui-input-inline">
                            <input type="text" placeholder="时间段" class="layui-input" id='due_date'>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">是否过期</label>
                        <div class="layui-input-inline mr0">
                            <select id="is_expired" name="is_expired">
                                <option value="">全部</option>
                                <option value="0">否</option>
                                <option value="1">是</option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">报价状态</label>
                        <div class="layui-input-inline mr0">
                            <select id="state" name="state">
                                <option value="">全部</option>
                                <option value="0">未报价</option>
                                <option value="1">暂存</option>
                                <option value="2">已报价</option>
                                <option value="3">已退回</option>
                                <option value="4">放弃报价</option>
                            </select>
                        </div>
                    </div>

                </div>
                    <div class="layui-form-item">

                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">车牌号</label>
                        <div class="layui-input-inline mr0">
                            <input name="vehicle_license_num" id="vehicle_license_num" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">车架号</label>
                        <div class="layui-input-inline mr0">
                            <input name="vehicle_frame_no" id="vehicle_frame_no" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">车型</label>
                        <div class="layui-input-inline mr0">
                            <input name="car_model" id="car_model" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </div>
                    </div>
                        <div class="layui-inline">
                            <label class="layui-form-label w-auto">询价人</label>
                            <div class="layui-input-inline mr0">
                                <input name="add_user_name" id="add_user_name" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                            </div>
                        </div>
                    <div class="layui-inline">
                        <button id="btnSearch" class="layui-btn icon-btn"><i class="layui-icon">&#xe615;</i>搜索
                        </button>
                        <button id="btnReset" class="layui-btn layui-btn-warm"><i class="layui-icon">&#xe669;</i>重置
                        </button>
                    </div>
                </div>
            </div>
            <table class="layui-table" id="infoTable" lay-filter="infoTable"></table>
        </div>
    </div>
</div>
<script type="text/javascript" src="../../js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../../js/jquery.cookie.js"></script>
<script type="text/javascript" src="../../common/layui/layui2.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../js/main.js"></script>
<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table','admin', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var admin = layui.admin;
        var laydate = layui.laydate;

        var userInfo = JSON.parse(getSessionStorage('gysuname'));
        laydate.render({
            elem: '#due_date'
            ,range: true
            ,trigger: 'click'
        });

        form.render();

        //渲染表格
        table.render({
            elem: '#infoTable',
            url: access_baseurl+'Inquiry/getList',
            where: {
                opt_user_id:userInfo.id
            },
            page: true,
            cellMinWidth: 90,
            cols: [[
                {type: 'numbers', title: '序号'},
                {field: 'bus_inquiry_no', title: '询价单号',width: 230,
                    templet: function (d) {
                        return "<a lay-event='show_detail' style='border-bottom: 1px solid blue;color: blue;'>"+d.bus_inquiry_no+"</a>";
                    }},
                {field: 'vehicle_frame_no', title: '车架号',width: 230},
                {field: 'vehicle_license_num', title: '车牌号',width: 160},
                {field: 'brand_name', title: '品牌名称'},
                {field: 'car_model', title: '车型名称'},
                // {field: 'city', title: '城市'},
                {field: 'add_datetime', title: '询价日期',width: 170},
                {field: 'is_expired', title: '是否过期',
                    templet:function (d) {
                        if (d.is_expired === 1) {
                            return "<span style='color: #fd1e11'>已过期</span>";
                        }else {
                            return "<span style='color: #11b7f4'>未过期</span>";
                        }
                    }},
                {field: 'state', title: '报价状态',
                    templet:function (d) {
                        if (d.inquiry_state === 3) {
                            return "<span style='color: #4b4a4a'>已关闭</span>";
                        }else if (d.state === 1) {
                            return "<span style='color: #f58d06'>暂存</span>";
                        }else if (d.state === 2 || d.state > 4) {
                            return "<span style='color: #11b7f4'>已报价</span>";
                        }else if (d.state === 3) {
                            return "<span style='color: #ee4848'>已退回</span>";
                        }else if (d.state === 4) {
                            return "<span style='color: #d84304'>放弃报价</span>";
                        }else {
                            return "<span style='color: #969595'>未报价</span>";
                        }
                    }
                },
                {field: 'add_user_name', title: '询价人',width: 90},
                {field: 'sum_num', title: '配件数量'},

            ]]
        });

        // 搜索按钮点击事件
        $('#btnSearch').click(function () {
            var where = getWhere();
            table.reload('infoTable', {where: where});
        });
        $('#btnReset').click(function () {
            // $('#keyWords').val('');
            $('#bus_inquiry_no').val(''),
            $('#vehicle_frame_no').val(''),
            $('#vehicle_license_num').val(''),
            $('#car_model').val(''),
            $('#service_no').val(''),
            $('#state').val(''),
            $('#bus_from_company_name').val(''),
            $('#is_expired').val(''),
            $('#due_date').val(''),
            form.render();
            var where = getWhere();
            table.reload('infoTable', {where: where});
        });
        // 工具条点击事件
        table.on('tool(infoTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'show_detail') { //修改
                var tag_type = [2,4,5,6,7];
                if(data.inquiry_state != 3 && !tag_type.includes(data.state)){
                    window.parent.go_to_page_general('./html/inquiry/quote.html','id='+data.id);
                }else{
                    window.parent.go_to_page_general('./html/inquiry/detail.html','id='+data.id);
                }
            }
        });

        // 关闭
        function doClose(id){
            layer.confirm('确定要关闭吗？', {
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                send_req('Inquiry/changeState', {id:id,state:3}, function (res) {
                    layer.closeAll('loading');
                    layer.msg('关闭成功', {icon: 1});
                    var where = getWhere();
                    table.reload('infoTable', {where: where});
                });
                return false;
            });
        }
        // 删除
        function doDelete(id) {
            layer.confirm('确定要删除吗？', {
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                send_req('Inquiry/del', {id:id}, function (res) {
                    layer.closeAll('loading');
                    layer.msg('删除成功', {icon: 1});
                    var where = getWhere();
                    table.reload('infoTable', {where: where});
                });
                return false;
            });
        }

        function getWhere() {
            var data = {
                bus_inquiry_no:$('#bus_inquiry_no').val(),
                vehicle_frame_no:$('#vehicle_frame_no').val(),
                vehicle_license_num:$('#vehicle_license_num').val(),
                car_model:$('#car_model').val(),
                service_no:$('#service_no').val(),
                state:$('#state').val(),
                bus_from_company_name:$('#bus_from_company_name').val(),
                is_expired:$('#is_expired').val(),
                due_date:$('#due_date').val(),
            };
            return data;
        }
    });
</script>
</body>
</html>